﻿using System;
using Home.MobileSales.Common.Entities;
using Home.MobileSales.Common.Models;

namespace Home.MobileSales.Common.Components
{
   class AddVisitDialogPresenter
    {
       private IAddVisitDialog _view;

       public AddVisitDialogPresenter(IAddVisitDialog view)
        {
            _view = view;
            _view.DataSource = DataManager.GetInstance().Buyers.GetBuyers();
           _view.SelectBuyer += SelectedBuyer;
           _view.SelectBuyPoint += SelectedBuyPoint;

        }

       public void SelectedBuyer (object sender, EventArgs e)
       {
           _view.BuyPoints = DataManager.GetInstance().BuyPoints.GetBuyPointsByBuyer(((Buyer) _view.Current).IdBuyer);
       }

       public void SelectedBuyPoint(object sender, EventArgs e)
       {
           _view.Adress = ((BuyPoint) _view.SelectedBuyPoint).Adress;
       }
    }
}
